package com.ruoyi.project.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.PubCodetableManager;
import com.ruoyi.project.system.service.IPubCodetableManagerService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 代码管理Controller
 * 
 * @author ruoyi
 * @date 2019-12-23
 */
@RestController
@RequestMapping("/system/manager")
public class PubCodetableManagerController extends BaseController
{
    @Autowired
    private IPubCodetableManagerService pubCodetableManagerService;

    /**
     * 查询代码管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:manager:list')")
    @GetMapping("/list")
    public TableDataInfo list(PubCodetableManager pubCodetableManager)
    {
        startPage();
        List<PubCodetableManager> list = pubCodetableManagerService.selectPubCodetableManagerList(pubCodetableManager);
        return getDataTable(list);
    }

    /**
     * 导出代码管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:manager:export')")
    @Log(title = "代码管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PubCodetableManager pubCodetableManager)
    {
        List<PubCodetableManager> list = pubCodetableManagerService.selectPubCodetableManagerList(pubCodetableManager);
        ExcelUtil<PubCodetableManager> util = new ExcelUtil<PubCodetableManager>(PubCodetableManager.class);
        return util.exportExcel(list, "manager");
    }

    /**
     * 获取代码管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:manager:query')")
    @GetMapping(value = "/{codetable}")
    public AjaxResult getInfo(@PathVariable("codetable") String codetable)
    {
        return AjaxResult.success(pubCodetableManagerService.selectPubCodetableManagerById(codetable));
    }

    /**
     * 新增代码管理
     */
    @PreAuthorize("@ss.hasPermi('system:manager:add')")
    @Log(title = "代码管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PubCodetableManager pubCodetableManager)
    {
        return toAjax(pubCodetableManagerService.insertPubCodetableManager(pubCodetableManager));
    }

    /**
     * 修改代码管理
     */
    @PreAuthorize("@ss.hasPermi('system:manager:edit')")
    @Log(title = "代码管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PubCodetableManager pubCodetableManager)
    {
        return toAjax(pubCodetableManagerService.updatePubCodetableManager(pubCodetableManager));
    }

    /**
     * 删除代码管理
     */
    @PreAuthorize("@ss.hasPermi('system:manager:remove')")
    @Log(title = "代码管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{codetables}")
    public AjaxResult remove(@PathVariable String[] codetables)
    {
        return toAjax(pubCodetableManagerService.deletePubCodetableManagerByIds(codetables));
    }
}
